﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace homework2
{
     class Rectangle: IShape
    {
        public double Length { set; get; }

        public double Width { set; get; }

        public Rectangle(double length, double width)
        {
            Length = length;
            Width = width;
        }

        public double Area
        {
            get
            {
                if (!isValid())
                    throw new InvalidOperationException("长方形长宽无效，无法计算");
                return Length * Width;
            }
        }

       public bool isValid()
        {
            return Length > 0 && Width > 0;
        }

        public string information => $"Rectangle[width:{Width}, length:{Length}]";
    }
}
